<?php
session_start(); 
// Connect to the Database
include("includes/connect.php");
include("functions/registration_functions.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/Main-Template.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Star Map Mobile</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" --><script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script><!-- InstanceEndEditable -->
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #CCCCCC}
-->
</style>
</head>

<body class="oneColFixCtrHdr">

<div id="container">
  <div id="header"><a href="index.php">home</a> | <a href="http://www.bmcstudiosllc.com/starmap/forum/">forum</a> | <a href="news.php">news</a> | <a href="download.php">download</a> | <a href="account.php">account</a> | <a href="register.php">register</a>
    <!-- end #header -->
  </div>
  <div id="mainContent">
    <table width="100%" border="1" bordercolor="#DDDDDD" cellpadding="10" bgcolor="#333333">
  <tr>
    <td width="750" height="200"><div align="center"><img src="images/smmbanner.png" alt="smm" width="750" height="200"></div></td>
  </tr>
  <tr>
    <td height="100" width="750"><div align="center" class="style1">
      <p>Developed by University of Miami Undergraduate Students</p>
        <p>Joey Kadin, Brandon Calabro, Mychal Sligh, Alex Alvarez</p>
      </div></td>
  </tr>
  <tr>
    <td><!-- InstanceBeginEditable name="MainContent" -->

<h2 class="WHITE_FONT">Authentication</h2>
<?php
// Check to see if login is Authentic.
    
    $username = $_POST['username'];
    $password = $_POST['password'];
    $username = strip_tags($username);
    $password = md5($password);
	
	$query = "SELECT * FROM `user_table` WHERE `username` = '$username' and `password` = '$password'"; 
    $result = mysql_query($query) or die("Cannot connect to database users table");
	$result2 = mysql_fetch_array($result);
	
	$getGID			= $result2['GID'];
	
    if($result2)
    {    
       $_SESSION['USER'] = $_POST['username'];
	   
	   if($getGID == 3)
	   {
	   $_SESSION['ADMIN'] = $_SESSION['USER'];
	   		print "<p>Administrator is Authentic</p>";  
 	   		print "<p>Redirecting...</p>";    
	     
       		print "<META HTTP-EQUIV = 'Refresh' Content = '2; URL =adminpanel.php'>"; // Needs to redirect to users account page like: myacct.php or something...
 	   }
	   else
	   {
 	   		print "<p>User is Authentic</p>";  
 	   		print "<p>Redirecting...</p>";    
	     
       		print "<META HTTP-EQUIV = 'Refresh' Content = '2; URL =memberpanel.php'>"; // Needs to redirect to users account page like: myacct.php or something...
		}
    }
    else
    {
 	   // This will redirect the user to the index page where they must log in again!
 	   
 	   print "<p>User is NOT Authentic</p>";  
 	   print "<p>Redirecting...</p>";      
       // This will refresh the page with the new session started
       print "<META HTTP-EQUIV = 'Refresh' Content = '2; URL =index.php'>";  // May need a slash in front of index.php
    }
?>
    <!-- InstanceEndEditable --></td>
  </tr>
</table>

	<!-- end #mainContent --></div>
  <div id="footer">
    <p>All rights reserved. Powered by <a href="http://www.bmcstudiosllc.com/">BMC Studios LLC.</a></p>
  <!-- end #footer --></div>
<!-- end #container --></div>
</body>
<!-- InstanceEnd --></html>
